var GameData = require('../module/gameData')();
cc.Class({
    extends: cc.Component,

    properties: {
        bg1: dragonBones.ArmatureDisplay,
        moveMusic: {
            default: [],
            type: [cc.AudioClip]
        },

    },

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        this.bg1.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.starPlay, this);
        this.node.on(cc.Node.EventType.TOUCH_START, this.onTouch, this);
        this.begin=false;
        GameData.playMusic(this.moveMusic[0], true);
    },
    starPlay() {
        this.bg1.playAnimation("JX", 0);
        this.begin=true;
    },
    onTouch() {
        if(this.begin){
            cc.director.preloadScene("Home", function () {
                cc.find("bg").zIndex=10;

                cc.find("bg").opacity = 0;
                cc.find("bg").runAction(
                    cc.sequence(
                        cc.fadeIn(1),
                        cc.callFunc(function () {
                            GameData.stopMusic();
                            cc.director.preloadScene("Home", function () {
                                cc.director.loadScene("Home");
                            });

                        })
                    )
                );
            });
        }
    },
    start() {

    },

    // update (dt) {},
});
